//
//  ScreenSize.swift
//  CodingTest
//
//  Created by LYPC on 2021/11/18.
//

import UIKit

final class ScreenSize {
    
    static let shared = ScreenSize()
    init() {
        p_refreshData()
    }
    
    private(set) var screenWidthRatio: CGFloat = 1
    private(set) var screenHeightRatio: CGFloat = 1
    private(set) var isIphonex = false
    
    //  默认参考 size = (375,667)
    private let designSize = CGSize.init(width: 375, height: 667)
    private func p_refreshData() {
        let screenWidth = UIScreen.main.bounds.size.width
        let screenHeight = UIScreen.main.bounds.size.height
        screenWidthRatio = screenWidth / designSize.width
        screenHeightRatio = screenHeight / designSize.height
                
        if #available(iOS 11.0, *),
           UIApplication.shared.delegate?
                .window??.safeAreaInsets.bottom != 0 {
            isIphonex = true
        }
    }
}

